<template>
  <div class="login">
    <el-form ref="form" :model="form" :rules="rules" label-width="80px">
      <el-form-item label="账号" prop="name">
        <el-input v-model="form.name"></el-input>
      </el-form-item>
      <el-form-item label="密码" prop="pwd">
        <el-input v-model="form.pwd"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">LOGIN</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  components: {},
  data() {
    return {
      form: {
        name: "",
        pwd: ""
      },
      rules: {
        name: this.$verify.checkThis.normal(true, "请填写用户名", 3, 6),
        pwd: this.$verify.checkThis.password(true)
      }
    };
  },
  computed: {},
  watch: {},
  methods: {
    onSubmit() {
      let userVO = this.ruleForm;
      this.$refs["form"].validate(valid => {
        if (valid) {
          // 校验成功...
          localStorage.userInfo = this.$funs.encrypt(JSON.stringify(this.form));
        } else {
          return false;
        }
      });
    }
  },
  created() {},
  mounted() {
    if (localStorage.userInfo) {
      let userInfo=this.$funs.decrypt(localStorage.userInfo);
      console.error(JSON.parse(userInfo))
    }
  }
};
</script>
<style lang='scss' scoped>
.el-form {
  width: 40%;
}
</style>